<?php
class Project_model extends CI_Model
{
	function __construct()
	{
		parent::__construct();
	}
	function getListProject($offset,$itemperpage)
	{
		$this->db->limit($itemperpage,$offset);
		$this->db->order_by('id','asc');
		$query=$this->db->get('project');
		return $query->result();
	}
	function getProject($projectId){
		$this->db->where('id',$projectId);
		$query = $this->db->get('project');
		return $query->row();
	}
	function getLastProjectId()
	{
		$this->db->select_max('id');
		$query = $this->db->get('project');
		return $query->row()->id;
	}
	function addProject($project)
	{
		$this->db->insert('project',$project);
	}
	function delete($libraryId){
		$this->db->where('id',$libraryId);
		$this->db->delete('project');
	}
	function update($project)
	{
		$this->db->where('id',$project['id']);
		$this->db->update('project',$project);
	}
	function getListFProject($offset,$itemperpage)
	{	
		$this->db->select('project.id,project.name,libary.image');
		$this->db->limit($itemperpage,$offset);
		$this->db->order_by('project.id','desc');
		$this->db->from('project');
		$this->db->group_by('project.id');
		$this->db->join('libary','project.id=libary.idproject','left');
		$query=$this->db->get();
		return $query->result();
	}
}